#pragma once

#include"HuffmanTree.h"
#include<string>

using std::string;

struct DataINFO
{
	DataINFO(char ch = 0, size_t frequency = 0, const string& code = "")
		:_ch(ch), _frequency(frequency), _code(code)
	{}

	bool operator>(const DataINFO& right)
	{
		return this->_frequency > right._frequency;
	}

	bool operator == (const DataINFO& right)
	{
		return this->_frequency == right._frequency
			&& this->_ch == right._ch && this->_code == right._code;
	}

	bool operator != (const DataINFO& right)
	{
		return this->_frequency != right._frequency;
	}

	DataINFO operator+(const DataINFO& right)
	{
		size_t frequency = this->_frequency + right._frequency;
		return DataINFO(0, frequency, "");
	}

	unsigned char _ch;
	size_t _frequency;
	string _code;
};


class FileCompress
{
	vector<DataINFO> fileDate;
	void GetHFCode(HuffmanNode<DataINFO>* proot);
	static string GetPostfix_File(const string& FilePath);
	static string GetFileName(const string& FilePath);
	static string GetLineINFO(FILE* FilePtr);

public:
	FileCompress();
	void Compress(const string& FilePath);
	void UnCompress(const string& FilePath);
};
